#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define STRING_LENGTH 20
#define MAX_QUESTION_NUM 10

typedef struct {
    char code[STRING_LENGTH];
    int question_num;
    int score;
} student;

void print_array(student[], int);
void swap_element(student[], int, int);
void quick_sort(student[], int);

int main()
{
    int student_num, question_num, passing_score;
    int score_list[MAX_QUESTION_NUM];
    while (scanf("%d", &student_num) != EOF) {
        if (student_num == 0) 
            break;

        scanf(" %d %d", &question_num, &passing_score);
        for (int i = 0; i < question_num; i++) 
            scanf(" %d", &score_list[i]);

        student* student_list = (student*)malloc(student_num * sizeof(student));
        for (int i = 0; i < student_num; i++) {
            scanf("%s %d", student_list[i].code, &student_list[i].question_num);
            int question_pos = 0;
            student_list[i].score = 0;
            for (int j = 0; j < student_list[i].question_num; j++) {
                scanf(" %d", &question_pos);
                student_list[i].score += score_list[question_pos - 1];
            }
        }

        quick_sort(student_list, student_num);

        int passing_student_num = 0;
        for (int i = 0; i < student_num; i++) 
            if (student_list[i].score >= passing_score)
                passing_student_num++;
        printf("%d\n", passing_student_num);
        print_array(student_list, passing_student_num);
    }
}

void swap_element(student array[], int i, int j) 
{
    // int temp;
    // temp = array[i];
    char temp_code[STRING_LENGTH];
    int temp_score;
    strcpy(temp_code, array[i].code);
    temp_score = array[i].score;
    // array[i] = array[j];
    strcpy(array[i].code, array[j].code);
    array[i].score = array[j].score;
    // array[j] = temp;
    strcpy(array[j].code, temp_code);
    array[j].score = temp_score;
}

void quick_sort(student array[], int num) 
{
    int i, last = 0;
    if (num <= 1)
        return;
    swap_element(array, 0, rand() % num);
    for (i = 1; i < num; i++) {
        if (array[i].score > array[0].score)
            swap_element(array, ++last, i);
    }

    swap_element(array, 0, last);
    quick_sort(array, last);
    quick_sort(array + last + 1, num - last - 1);
}

void print_array(student array[], int num) 
{
    for (int i = 0; i < num; i++)
        printf("%s %d\n", array[i].code, array[i].score);
}